export const getAvatar = function(context){
  return (
    context.data.userInfo.avatar ||
    wx.getStorageSync('avatarUrl') || 
    getApp().globalData.userInfo.avatarUrl
  )
}

export const setAvatarAndUserInfo = (avatar: any, context: any,  userInfo: any) => {
  const newUserInfo = {
    ...userInfo,
    avatar
  }
  wx.setStorageSync('avatar', avatar)
  wx.setStorageSync('userInfo', newUserInfo);
  getApp().globalData.userInfo = newUserInfo;
  context.setData({
    userInfo: newUserInfo
  })
}